package com.ruoyi.modules.service.impl;

import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.modules.domain.Credit;
import com.ruoyi.modules.mapper.CreditMapper;
import com.ruoyi.modules.service.CreditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 字典 业务层处理
 *
 * @author tlgen
 */
@Service
public class CreditServiceImpl implements CreditService
{
    @Autowired
    private CreditMapper creditMapper;

    /**
     * 根据条件分页查询字典数据
     */
    @Override
    public List<Credit> selectCreditList(Credit Credit)
    {
        return creditMapper.selectCreditList(Credit);
    }

    /**
     * 根据字典数据ID查询信息
     */
    @Override
    public Credit selectCreditById(Long creditId)
    {
        return creditMapper.selectCreditById(creditId);
    }

    @Override
    public List<Credit> selectCreditByName(String userName) {
        return creditMapper.selectCreditByName(userName);
    }

    @Override
    public Credit selectCreditByDuringYearAndUserName(String duringYear, String userName) {
        return creditMapper.selectCreditByDuringYearAndUserName(duringYear, userName);
    }

    /**
     * 根据用户名查询最新添加的一条记录
     * @param userName
     * @return
     */
    @Override
    public Credit selectNewCreateByUserName(String userName) {
        return creditMapper.selectNewCreateByUserName(userName);
    }

    /**
     * 批量删除字典数据信息
     */
    @Override
    public int deleteCreditByIds(Long[] creditIds)
    {
        int row = creditMapper.deleteCreditByIds(creditIds);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 新增保存字典数据信息
     */
    @Override
    public int insertCredit(Credit Credit)
    {
        int row = creditMapper.insertCredit(Credit);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    /**
     * 修改保存字典数据信息
     */
    @Override
    public int updateCredit(Credit Credit)
    {
        int row = creditMapper.updateCredit(Credit);
        if (row > 0)
        {
            DictUtils.clearDictCache();
        }
        return row;
    }

    @Override
    public boolean updateCreditIdentityFileOfFront(Long creditId, String identityPathOfFront) {
        return creditMapper.updateCreditIdentityFileOfFront(creditId, identityPathOfFront) > 0;
    }

    @Override
    public boolean updateCreditIdentityFileOfReverse(Long creditId, String identityPathOfReverse) {
        return creditMapper.updateCreditIdentityFileOfReverse(creditId, identityPathOfReverse) > 0;
    }

    @Override
    public boolean updateCreditUploadWord(Long creditId, String uploadWordPath, String uploadWordName) {
        return creditMapper.updateCreditUploadWord(creditId, uploadWordPath, uploadWordName) > 0;
    }

    @Override
    public boolean updatePdfWithSignature(Long creditId, String pdfWithSignaturePath, String pdfWithSignatureName) {
        return creditMapper.updatePdfWithSignature(creditId, pdfWithSignaturePath, pdfWithSignatureName) > 0;
    }

    @Override
    public boolean updateFirstSignature(Long creditId, String firstSignature) {
        return creditMapper.updateFirstSignature(creditId, firstSignature) > 0;
    }

    @Override
    public boolean updateSecondSignature(Long creditId, String secondSignature) {
        return creditMapper.updateSecondSignature(creditId, secondSignature) > 0;
    }

    @Override
    public boolean updateUploadReceiptWord(Long creditId, String uploadReceiptWord) {
        return creditMapper.updateUploadReceiptWord(creditId, uploadReceiptWord) > 0;
    }

    @Override
    public boolean updateLetterOfAdmission(Long creditId, String letterOfAdmission) {
        return creditMapper.updateLetterOfAdmission(creditId, letterOfAdmission) > 0;
    }

    @Override
    public boolean updateCertificat(Long creditId, String certificat) {
        return creditMapper.updateCertificat(creditId, certificat) > 0;
    }

    @Override
    public boolean updateHouseholdRegistrationBook(Long creditId, String householdRegistrationBook) {
        return creditMapper.updateHouseholdRegistrationBook(creditId, householdRegistrationBook) > 0;
    }

}
